package com.boot.cluster.worker.bean;

import com.boot.cluster.worker.runner.Combiner;
import com.boot.cluster.worker.runner.Work;
import com.boot.cluster.worker.splitter.Splitter;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;



public class TaskRunner implements Serializable{

	private static final long serialVersionUID = -938835970874273006L;

	private String id;

	/***任务处理 计算功能***/
	private Class <? extends Work> wcls;

	/***任务处理 合并功能***/
	private Class <? extends Combiner> cbls;

	private Date createTime;

	private Long timeout=30*60L;

	private Splitter splitter;

	private Map<String,Object> param;


	public TaskRunner() {
		this.id =  UUID.randomUUID().toString().replaceAll("-", "");
		this.createTime= new Date();
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Class<? extends Work> getWcls() {
		return this.wcls;
	}

	public void setWcls(Class<? extends Work> wcls) {
		this.wcls = wcls;
	}

	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Map<String, Object> getParam() {
		return this.param;
	}

	public void setParam(Map<String, Object> param) {
		this.param = param;
	}

	public void addParam(String key ,Object value) {
		if(this.param==null) {
			this.param= new HashMap<>();
		}
		this.param.put(key, value);
	}

	public void addParam(Map<String,Object> params) {
		if(this.param==null) {
			this.param= new HashMap<>();
		}
		this.param.putAll(params);
	}


	public Class <? extends Combiner> getCbls() {
		return this.cbls;
	}

	public void setCbls(Class <? extends Combiner> cbls) {
		this.cbls = cbls;
	}

	public Long getTimeout() {
		return this.timeout;
	}

	public void setTimeout(Long timeout) {
		this.timeout = timeout;
	}

	public Splitter getSplitter() {
		return this.splitter;
	}

	public void setSplitter(Splitter splitter) {
		this.splitter = splitter;
	}
}
